package cls.inner;

/**
 * @author mubei
 * @date 2021/12/21
 * @description
 * 演示局部内部类   好离谱..........
 */
public class LocalInnerClass {
    public static void main(String[] args) {
        Outer01 outer01 = new Outer01();
        outer01.m1();
        System.out.println(outer01.hashCode());
    }
}


class Outer01{
    private int n1 = 10;
    public void m1(){
        class Inner01 {
            public void f1(){
                // 可以直接访问外部类的所有成员  包含私有
                System.out.println("访问外部类的私有属性:"+n1);
                int n1 = 20;
                System.out.println("就近原则:"+n1);

                System.out.println("强制使用外部类的属性:"+Outer01.this.n1);
                //Outer01.this 谁调用 指向谁
                System.out.println(Outer01.this.hashCode());
            }
        }

        class Inner02 extends Inner01{

        }
        Inner01 inner01 = new Inner01();
        inner01.f1();
    }
}
